<template>
	<view>
		<view class="padding">您好：<text class="text-red">{{loginId}}({{name}})</text>，欢迎来到剑狮科技控制台。</view>
		<view class="grid col-3 text-center">
			<view class="bg-blue padding">
				<view><text class="cuIcon-moneybag"></text>总收入</view>
				<view class="padding-xs text-xl text-bold">￥{{(allSaleCount/100).toFixed(2)}}</view>
			</view>
			<view class="bg-orange padding">
				<view><text class="cuIcon-moneybag"></text>今日收入</view>
				<view class="padding-xs text-xl text-bold">￥{{(todaySaleCount/100).toFixed(2)}}</view>
			</view>
			<view class="bg-green padding">
				<view><text class="cuIcon-taoxiaopu"></text>在线设备</view>
				<view class="padding-xs text-xl text-bold">{{onlineMachineCount}}台</view>
			</view>
		</view>
		<view class="grid col-3 text-center solid-top">
			<view v-for="(item,index) in list" :key="index" :class="index%4!=3?'solid-right':''" class="solid-bottom padding flex flex-direction" @tap="navigateTo(item.path)">
				<view :class="'text-sl text-'+item.color">
				  <text :class="'cuIcon-'+item.icon"></text>
				</view>
				<view>{{item.name}}</view>
			</view>
			<view class="solid-right solid-bottom padding flex flex-direction" @tap="clickExit">
				<view class="text-sl text-orange">
				  <text class="cuIcon-exit"></text>
				</view>
				<view>退出</view>
			</view>
		</view>
	</view>
	
</template>

<script>
	export default {
		data() {
			return {
				loginId:'',
				name:'',
				allSaleCount:0,
				todaySaleCount:0,
				onlineMachineCount:0,
				list:[
					{
						path:'/pages/customer/machineList',
						icon:'taoxiaopu',
						color:'orange',
						name:'设备管理'
					},
					{
						path:'/pages/admin/customer',
						icon:'friend',
						color:'blue',
						name:'订单管理'
					},
					{
						path:'/pages/customer/changePassword',
						icon:'lock',
						color:'blue',
						name:'修改密码'
					}
				]
			};
		},
		onShow(){
			this.$u.api.customer_getData({}).then(data => {
				console.log(data);
				Object.assign(this,data);
			})
		},
		methods:{
			navigateTo(url){
				uni.navigateTo({
					url:url
				})
			},
			clickExit(){
				uni.removeStorageSync('customer_id');
				uni.removeStorageSync('customer_token');
				console.log(11);
				uni.navigateTo({
					url:'/pages/customer/login'
				});
			}
		}
	}
</script>

<style lang="scss">
.grid-text{
	color: white
}
.gird-text2{}
</style>
